<%= content_for :title, '分类 - 设置' %>

<div class="uk-grid">
  <%= render 'tab_head' %>

  <div class="uk-width-medium-3-4">
    <% if flash[:notice].present? %>
        <div class="uk-alert uk-alert-success"><%= flash[:notice] %></div>
    <% end %>

    <div class="uk-clearfix">
      <%= link_to content_tag(:i, nil, class: 'uk-icon-plus'), '#new-modal', class: 'uk-button uk-float-right', 'data-uk-modal' => '' %>
    </div>
    <table class="uk-table uk-table-striped">
      <thead>
      <tr>
        <th>页面标题</th>
        <th>路径</th>
        <th>#</th>
      </tr>
      </thead>
      <tbody>
      <% links.each do |title, link| %>
          <tr>
            <td><%= title %></td>
            <td><%= link %></td>
            <td>
              <%= link_to '', update_link_admin_settings_path(_action: 'drop', title: title, type: type, back_url: back_url), method: :put, class: 'uk-icon-button uk-icon-times' %>
            </td>
          </tr>
      <% end %>
      </tbody>
    </table>
  </div>
</div>


<div id="new-modal" class="uk-modal">
  <div class="uk-modal-dialog">
    <a class="uk-modal-close uk-close"></a>
    <%= form_tag update_link_admin_settings_path, method: :put, class: 'uk-form' do %>
        <%= hidden_field_tag :_action, 'create' %>
        <%= hidden_field_tag :type, type %>
        <%= hidden_field_tag :back_url, back_url %>

        <fieldset>
          <legend>添加页面链接</legend>

          <div class="uk-form-row">
            <%= text_field_tag :title, nil, class: 'uk-width-1-1', placeholder: '标题' %>
          </div>

          <div class="uk-form-row">
            <%= text_field_tag :link, nil, class: 'uk-width-1-1', placeholder: '路径' %>
          </div>

          <div class="uk-form-row uk-clearfix">
            <%= submit_tag nil, class: 'uk-button uk-button-primary uk-float-right' %>
          </div>
        </fieldset>
    <% end %>
  </div>
</div>